/*
 * MainFrame.java
 *
 * Created on __DATE__, __TIME__
 */

package com.lay.gui;

//import java.awt.BorderLayout;
//import java.awt.Container;
import java.awt.HeadlessException;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.event.AncestorEvent;

//import javax.swing.WindowConstants;

import com.tools.CpuTools;

/**
 *
 * @author  __USER__
 */
public class MainFrame extends javax.swing.JFrame {

	/** Creates new form MainFrame */
	public MainFrame() {
		initComponents();
	}

	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		image = new javax.swing.JLabel();
		jMenuBar1 = new javax.swing.JMenuBar();
		jMenu1 = new javax.swing.JMenu();
		mnuSetCpu = new javax.swing.JMenuItem();
		mnuDisplayCpu = new javax.swing.JMenuItem();
		mnuExit = new javax.swing.JMenuItem();
		jMenu2 = new javax.swing.JMenu();
		mnuAuto = new javax.swing.JMenuItem();
		jMenu3 = new javax.swing.JMenu();
		mnuVis = new javax.swing.JMenuItem();
		jMenu4 = new javax.swing.JMenu();
		mnuBind = new javax.swing.JMenuItem();
		jMenu5 = new javax.swing.JMenu();
		mnuAbout = new javax.swing.JMenuItem();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("CpuFreq");
		setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
		image.setIcon(new ImageIcon("img.jpg"));
//		image.addAncestorListener(new javax.swing.event.AncestorListener() {
//			public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
//			}
//
//			public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
//				imageAncestorAdded(evt);
//			}
//
//			public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
//			}
//		});

		jMenuBar1.setPreferredSize(new java.awt.Dimension(197, 41));

		jMenu1.setText("Set");
		jMenu1.setFont(new java.awt.Font("Dialog", 1, 18));

		mnuSetCpu.setFont(new java.awt.Font("Dialog", 1, 14));
		mnuSetCpu.setText("Set Cpu");
		mnuSetCpu.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				mnuSetCpuActionPerformed(evt);
			}
		});
		jMenu1.add(mnuSetCpu);

		mnuDisplayCpu.setFont(new java.awt.Font("Dialog", 1, 14));
		mnuDisplayCpu.setText("Display Cpu");
		mnuDisplayCpu.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				mnuDisplayCpuActionPerformed(evt);
			}
		});
		jMenu1.add(mnuDisplayCpu);

		mnuExit.setFont(new java.awt.Font("Dialog", 1, 14));
		mnuExit.setText("Exit");
		mnuExit.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				mnuExitActionPerformed(evt);
			}
		});
		jMenu1.add(mnuExit);

		jMenuBar1.add(jMenu1);

		jMenu2.setText("Auto");
		jMenu2.setFont(new java.awt.Font("Dialog", 1, 18));

		mnuAuto.setFont(new java.awt.Font("Dialog", 1, 14));
		mnuAuto.setText("Automatic frequency");
		mnuAuto.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				mnuAutoActionPerformed(evt);
			}
		});
		jMenu2.add(mnuAuto);

		jMenuBar1.add(jMenu2);

		jMenu3.setText("Ksar");
		jMenu3.setFont(new java.awt.Font("Dialog", 1, 18));

		mnuVis.setFont(new java.awt.Font("Dialog", 1, 14));
		mnuVis.setText("Visuslization");
		mnuVis.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				mnuVisActionPerformed(evt);
			}
		});
		jMenu3.add(mnuVis);

		jMenuBar1.add(jMenu3);

		jMenu4.setText("Bind");
		jMenu4.setFont(new java.awt.Font("Dialog", 1, 18));

		mnuBind.setFont(new java.awt.Font("Dialog", 1, 14));
		mnuBind.setText("Kernal bind");
		mnuBind.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				mnuBindActionPerformed(evt);
			}
		});
		jMenu4.add(mnuBind);

		jMenuBar1.add(jMenu4);

		jMenu5.setText("Help");
		jMenu5.setFont(new java.awt.Font("Dialog", 1, 18));

		mnuAbout.setFont(new java.awt.Font("Dialog", 1, 14));
		mnuAbout.setText("About");
		mnuAbout.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				mnuAboutActionPerformed(evt);
			}
		});
		jMenu5.add(mnuAbout);

		jMenuBar1.add(jMenu5);

		setJMenuBar(jMenuBar1);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(image,
				javax.swing.GroupLayout.Alignment.TRAILING,
				javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE));
		layout.setVerticalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(image,
				javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	//	private void imageAncestorAdded(javax.swing.event.AncestorEvent evt) {
	//		// TODO add your handling code here:
	//	}

	private void mnuVisActionPerformed(java.awt.event.ActionEvent evt) {
		CpuTools cpuTools = new CpuTools();
		cpuTools.ksarCpuFreq();
	}

	private void mnuAboutActionPerformed(java.awt.event.ActionEvent evt) {
		AboutFrame aboutFrame = new AboutFrame();
		aboutFrame.setVisible(true);
	}

	private void mnuBindActionPerformed(java.awt.event.ActionEvent evt) {
		BindFrame bindFrame = new BindFrame();
		bindFrame.setVisible(true);
	}

	private void mnuAutoActionPerformed(java.awt.event.ActionEvent evt) {
		AxisFrame frame;
		try {
			frame = new AxisFrame();
			frame.setBounds(100, 100, 1100, 480);
			//frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
			frame.setVisible(true);
			frame.setDefaultCloseOperation(HIDE_ON_CLOSE);
		} catch (HeadlessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	private void mnuDisplayCpuActionPerformed(java.awt.event.ActionEvent evt) {
		DisplayCpuFrame displayCpuFrame = new DisplayCpuFrame();
		displayCpuFrame.setVisible(true);
	}

	private void mnuSetCpuActionPerformed(java.awt.event.ActionEvent evt) {
		SetCpuFrame setCpuFrame = new SetCpuFrame();
		setCpuFrame.setVisible(true);
	}

	private void mnuExitActionPerformed(java.awt.event.ActionEvent evt) {
		System.exit(0);
	}

	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				MainFrame mFrame = new MainFrame();
				mFrame.setVisible(true);

			}
		});
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JLabel image;
	private javax.swing.JMenu jMenu1;
	private javax.swing.JMenu jMenu2;
	private javax.swing.JMenu jMenu3;
	private javax.swing.JMenu jMenu4;
	private javax.swing.JMenu jMenu5;
	private javax.swing.JMenuBar jMenuBar1;
	private javax.swing.JMenuItem mnuAbout;
	private javax.swing.JMenuItem mnuAuto;
	private javax.swing.JMenuItem mnuBind;
	private javax.swing.JMenuItem mnuDisplayCpu;
	private javax.swing.JMenuItem mnuExit;
	private javax.swing.JMenuItem mnuSetCpu;
	private javax.swing.JMenuItem mnuVis;
	// End of variables declaration//GEN-END:variables

}